package com.spica.platform.user.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spica.platform.base.model.SysUser;
import com.spica.platform.db.mapper.BaseMapper;
import com.spica.platform.user.model.request.SysUserQueryParam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 用户表 Mapper 接口
 */
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {
	
	/**
	 * 数据脱敏,脱敏感词
	 * 插入时会把 sysUser.username, sysUser.mobile, sysUser.password脱敏
	 */
	@Options(useGeneratedKeys = true, keyProperty = "id")
	@Insert("insert into sys_user( username,password,mobile,type,create_time,update_time) values (#{username,typeHandler=com.spica.platform.db.typehandler.CryptTypeHandler},  #{password,typeHandler=com.spica.platform.db.typehandler.CryptTypeHandler}, #{mobile,typeHandler=com.spica.platform.db.typehandler.CryptTypeHandler}, #{type}, #{createTime}, #{updateTime})")
	void insertEnc(SysUser sysUser);

	/**
	 * 脱敏查询,脱名感词
	 * 查询参数sysUser.username, sysUser.mobile在查询时,会被脱敏
	 * 查询结果sysUser.username, sysUser.password, sysUser.mobile在返回时,会被脱敏
	 */
    List<SysUser> selectListEnc(Page<SysUser> page, SysUser sysUser);

	/**
	 * 分页查询用户列表
	 * @param page
	 * @param sysUserQueryParam
	 * @return
	 */
	List<SysUser> selectListByParam(Page<SysUser> page, @Param("sysUserQueryParam") SysUserQueryParam sysUserQueryParam);
}
